from tfpp.action.action import Action, MetaAction
import os

class MetaScript(MetaAction):
    def get_properties(self):
        return ('command', )
    
    def get_clazz(self):
        return Mail

class Mail(Action):
    def action(self):
        fout = os.popen4(self.data['command'])[1]
        result = fout.read().rstrip("\n\t\r")
        return result

    def as_text(self):
        result = "os.system("
        result += "%s)" % self.data['command']
        return result

    def as_html(self):
        return self.as_text(self)
